package com.ejd.access.bean;

import com.ejd.utils.CommonUtil;
import com.ejd.utils.TreeUtil;
import com.ejd.web.bo.BaseEntity;


@SuppressWarnings("serial")
public class Resource extends BaseEntity {	
        
	private String name;
        
	private String description;
        
	private boolean online;
        
	private Integer bitPosition;
        
	private String resourceUrl;
	
	private String authorityUrl;
        
	private String treeCode;
	
	private String ptreeCode;
	
	private boolean leaf;
	
	private boolean reloadTree;
	
	private String pid;
	
	private boolean assigned;
	
	private String roleCode;
	
	//for import data
	private String tempId;
	//for import data
	private String serviceId;
	
	private String icon;
	
	//0:menu right 1:special right
	private Integer type;
	
	private String folder;
	//the resource's checkbox can't be checked;
	private boolean disabled;
	
	private boolean specialRight;
	
	public String getRootTreeCode() {
		return CommonUtil.isEmpty(treeCode) ? "" : treeCode.substring(0, TreeUtil.INIT_TREE_LENGTH);
	}
	
	public boolean isSpecialRight() {
		return specialRight;
	}

	public void setSpecialRight(boolean specialRight) {
		this.specialRight = specialRight;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public boolean isDisabled() {
		return disabled;
	}

	public void setDisabled(boolean disabled) {
		this.disabled = disabled;
	}

	public String getFolder() {
		return folder;
	}

	public void setFolder(String folder) {
		this.folder = folder;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getTempId() {
		return tempId;
	}

	public void setTempId(String tempId) {
		this.tempId = tempId;
	}

	public String getRoleCode() {
		return roleCode;
	}

	public void setRoleCode(String roleCode) {
		this.roleCode = roleCode;
	}

	public boolean isAssigned() {
		return assigned;
	}

	public void setAssigned(boolean assigned) {
		this.assigned = assigned;
	}

	public String getPid() {
		return pid;
	}

	public void setPid(String pid) {
		this.pid = pid;
	}

	//get user's service select option's indent
	public String getIndent() {
		StringBuffer indent = new StringBuffer();
		int length = treeCode.length() - TreeUtil.INIT_TREE_LENGTH;
		for (int i = 0; i < length / TreeUtil.INIT_TREE_LENGTH; i++) {
			indent.append("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|--");
		}
		//indent.append("-----");
		return indent.toString();
	}
	
	public boolean isReloadTree() {
		return reloadTree;
	}

	public void setReloadTree(boolean reloadTree) {
		this.reloadTree = reloadTree;
	}

	//get parent tree code
	public String getPtreeCode() {
		if (CommonUtil.isNotEmpty(treeCode)) {
			return treeCode.substring(0, treeCode.length() - TreeUtil.INIT_TREE_LENGTH);
		} 
		return ptreeCode;
	}

	public void setPtreeCode(String ptreeCode) {
		this.ptreeCode = ptreeCode;
	}
	
	//get root tree code
	public String getRootCode() {
		return treeCode.substring(0, TreeUtil.INIT_TREE_LENGTH);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
		
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public boolean isOnline() {
		return online;
	}

	public void setOnline(boolean online) {
		this.online = online;
	}

	public boolean isLeaf() {
		return leaf;
	}

	public void setLeaf(boolean leaf) {
		this.leaf = leaf;
	}

	public Integer getBitPosition() {
		return bitPosition;
	}

	public void setBitPosition(Integer bitPosition) {
		this.bitPosition = bitPosition;
	}
		
	public String getServiceId() {
		return serviceId;
	}

	public void setServiceId(String serviceId) {
		this.serviceId = serviceId;
	}
		
	public String getResourceUrl() {
		return resourceUrl;
	}

	public void setResourceUrl(String resourceUrl) {
		this.resourceUrl = resourceUrl;
	}

	public String getAuthorityUrl() {
		return authorityUrl;
	}

	public void setAuthorityUrl(String authorityUrl) {
		this.authorityUrl = authorityUrl;
	}

	public String getTreeCode() {
		return treeCode;
	}

	public void setTreeCode(String treeCode) {
		this.treeCode = treeCode;
	}
	
}
